home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / malloc / valloc.c < prev    next >
C/C++ Source or Header  |  1993-08-12  |  1KB  |  47 lines

  1. /* Allocate memory on a page boundary.
  2.    Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
  3.  
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.
  18.  
  19.    The author may be reached (Email) at the address mike@ai.mit.edu,
  20.    or (US mail) as Mike Haertel c/o Free Software Foundation.  */
  21.  
  22. #if defined (__GNU_LIBRARY__) || defined (_LIBC)
  23. #include <stddef.h>
  24. #include <sys/cdefs.h>
  25. extern size_t __getpagesize __P ((void));
  26. #else
  27. #include "getpagesize.h"
  28. #define     __getpagesize()    getpagesize()
  29. #endif
  30.  
  31. #ifndef    _MALLOC_INTERNAL
  32. #define    _MALLOC_INTERNAL
  33. #include <malloc.h>
  34. #endif
  35.  
  36. static size_t pagesize;
  37.  
  38. __ptr_t
  39. valloc (size)
  40.      size_t size;
  41. {
  42.   if (pagesize == 0)
  43.     pagesize = __getpagesize ();
  44.  
  45.   return memalign (pagesize, size);
  46. }
  47.